package com.carpedil.shirodemo.system.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.carpedil.shirodemo.common.validate.Create;
import com.carpedil.shirodemo.common.validate.Update;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;

/**
 * 用户表
 *
 * @author carpedil
 * @since 2021-01-05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Component
public class User extends Model {

  private static final long serialVersionUID = 1L;

  @TableId(value = "user_id", type = IdType.AUTO)
  @NotBlank(
      groups = {Update.class},
      message = "id不能为空")
  private Integer userId;

  /** 用户名 */
  @NotBlank(
      groups = {Create.class, Update.class},
      message = "用户名不能为空")
  private String username;

  /** 密码 */
  @NotBlank(
      groups = {Create.class},
      message = "密码不能为空")
  private String password;

  /** 盐 */
  private String salt;

  /** 邮箱 */
  private String email;

  /** 账号状态: 0: 未激活, 1: 已激活. */
  private Integer status;

  /** 最后登录时间 */
  private LocalDateTime lastLoginTime;

  /** 创建时间 */
  private LocalDateTime createTime;

  /** 修改时间 */
  private LocalDateTime modifyTime;

  /** 注册激活码 */
  private String activeCode;

  /** 部门ID */
  private Integer deptId;
  /** 部门名称 */
  @TableField(exist = false)
  private String deptName;

  @TableLogic private Integer deleted;
}
